package com.olclass.web.util;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

@XmlRootElement(name = "BaseObjectResponse")
@XmlAccessorType(XmlAccessType.NONE)
public class EasyUIResponse extends BaseResponse{

	@XmlElement
	protected String status = CommonConstants.RESPONSE_STATUS_OK;
	
	@XmlElement
	protected String message = "";
	
	@XmlElement
	protected Long total = 0L;
	
	@XmlElement
	List rows = null;
    
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public List getRows() {
		return rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}

	public static EasyUIResponse buildNoLoginResponse() {
		EasyUIResponse response = new EasyUIResponse();

		response.setStatus(CommonConstants.RESPONSE_STATUS_LOGINOUT);
		response.setMessage("用户未登录或已登录超时，请重新登录!");

		return response;
	}

	public static EasyUIResponse buildFailuaResponse(Exception e) {
		EasyUIResponse response = new EasyUIResponse();
		response.setStatus(CommonConstants.RESPONSE_STATUS_FAILURE);
		response.setMessage(e.getMessage());
		return response;
	}

	public static EasyUIResponse buildFailuaResponse(String error) {
		EasyUIResponse response = new EasyUIResponse();
		response.setStatus(CommonConstants.RESPONSE_STATUS_FAILURE);
		response.setMessage(error);
		return response;
	}
	
	public static EasyUIResponse buildSuccessResponse(){
		EasyUIResponse response = new EasyUIResponse();
		response.setStatus(CommonConstants.RESPONSE_STATUS_OK);
		return response;	
	}
	
	public static EasyUIResponse buildSuccessResponse(String message){
		EasyUIResponse response = new EasyUIResponse();
		response.setStatus(CommonConstants.RESPONSE_STATUS_OK);
		response.setMessage(message);
		return response;	
	}

}
